const router = require("koa-router")();
const MovieModel = require("../../models/movie");
router.get("/api/movie/:m",async ctx=>{
    // ms是get传值传入的需要查询的集合名
    let {m} = ctx.request.params;
    //封装好的数据模型函数，参数是集合名
    var data = await MovieModel(m).find().sort({rating:-1});
    if(data.length){
        ctx.body = {
            code:200,
            res:data,
            request:"GET /api/top250"
        }
    }else{
        ctx.body = {
            code:400,
            msg:"输入的字段不合法！"
        }
    }
})
module.exports = router;